package cate.game.activity.herodirectbuy.msg;

import cate.game.GameBody;
import cate.game.activity.herodirectbuy.HeroDirectBuyPO;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInputTemplate;
import cate.game.client.msg.id.MsgIdBHeroDirectBuy;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

public class DirectRefreshReq extends MsgInputTemplate {
    @NoteField("功能ID")
    public int funcId;
    @NoteField("数量")
    public int num;
    @Override
    public MsgConfig conf() {
        return MsgIdBHeroDirectBuy.DIRECT_REFRESH_REQ;
    }

    @Override
    public void action(GameBody game, Role role) throws Exception {
        HeroDirectBuyPO single = role.getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            game.notice.message(role, "活动未开启");
            return;
        }
        EcResult<Void> r = single.refreshList(num);
        if (!r.ok()) {
            game.notice.message(role, r.message);
        }
    }

}
